package io;

import java.io.*;
import java.util.ArrayList;

public class OISDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("student.txt");
        ObjectInputStream ois = null;
        try {
            ois = new ObjectInputStream(fis);
            Object o;
            while (true) {
                o = ois.readObject();
                Student stu = (Student) o;
                System.out.println(stu);
            }
        } catch (EOFException e) {  //此处捕获EOFException

            System.out.println("已经达到文件末尾");

        } catch (IOException e) {

            e.printStackTrace();

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
            ois.close();
        }

    }

}

        /*        FileInputStream fis = new FileInputStream("student.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Object o = ois.readObject();
        Student zs = (Student) o;
        System.out.println(zs);
        ois.close();*/

